package com.tulele.vtool.handler;

import com.tulele.vtool.model.ArticleInfo;
import com.tulele.vtool.model.reqEntity.ButtonEventReqBean;
import com.tulele.vtool.model.reqEntity.HeadlineReqBean;
import com.tulele.vtool.model.respEntity.RespData;
import com.tulele.vtool.model.respEntity.ReturnCode;
import com.tulele.vtool.service.HeadlineService;
import com.tulele.vtool.service.IESService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@Slf4j
@RestController
public class ESHandler {

    @Autowired
    private IESService esService;

    /**
     * 头条首页
     * @param userId
     * @return
     */
    @PostMapping(value = "/putButtonEvent", produces = "application/json;charset=UTF-8")
    public RespData putButtonEvent(@RequestHeader("userId") String userId,@RequestHeader("identifying") String springProfilesActive,@RequestBody ButtonEventReqBean buttonEvent) {

        try {
            esService.putButtonEventIndex(Integer.parseInt(userId), springProfilesActive, buttonEvent.getEventcode(), buttonEvent.getEventname());
        }catch (IOException e){}

        //Map<String,List<Object>> map  = this.headlineService.selectHeadlineByGzhCode(springProfilesActive);
        RespData respData = new RespData();
        respData.setCode(ReturnCode.NORMAL_SUCC);
        //respData.setData(map);
        respData.setMsg("正常");
        return respData;
    }
}
